package com.luoluo.controller;

import com.luoluo.pojo.TouristsLeaveWord;
import com.luoluo.service.impl.TouristsLeaveWordServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
public class TouristsLeaveWordController {

    @Autowired
    TouristsLeaveWordServiceImpl touristsLeaveWordServiceImpl;
    /**
     * 查询留言，按id查询，查询用户数据
     * @return
     */
    @GetMapping("touristsleaveword/{id}")
    public String selectById(@PathVariable("id")Integer id, Model model){
        TouristsLeaveWord touristsLeaveWord = touristsLeaveWordServiceImpl.selectByPrimaryKey(id);
        System.out.println("游客查询完成..."+touristsLeaveWord);
        model.addAttribute("touristsLeaveWord", touristsLeaveWord);
        return "select";
    }
    /**
     * 查询全部
     */
    @GetMapping("touristsleaveword")
    public String index(Model model){
        model.addAttribute( "data", touristsLeaveWordServiceImpl.selectAll());
        return "all";
    }
}